package com.itcast.admin.controller;


import com.itcast.admin.domain.request.CreateSetmealReqDTO;
import com.itcast.admin.domain.request.SetmealPageReqDTO;
import com.itcast.admin.domain.response.GetSetmealResDTO;
import com.itcast.admin.domain.response.ItemAndGroupResDTO;
import com.itcast.admin.domain.response.SetmealPagerResDTO;
import com.itcast.admin.service.ISetmealService;
import com.jzo2o.common.model.PageResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 套餐表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-05
 */
@RestController
@RequestMapping("/admin/setmeal")
public class SetmealController {

    @Autowired
    private ISetmealService setmealService;
    @GetMapping("/pageQuery")
    @ApiOperation("获取套餐类型列表")
    public PageResult<SetmealPagerResDTO> pageQuery(SetmealPageReqDTO setmealPageReqDTO) {
        return setmealService.pageQuery(setmealPageReqDTO);
    }
    @PostMapping
    @ApiOperation("新增套餐")
    public void createSetmeal(@RequestBody CreateSetmealReqDTO createSetmealReqDTO) {
        setmealService.createSetmeal(createSetmealReqDTO);
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询套餐")
    public GetSetmealResDTO getSetmealById(@PathVariable Integer id) {
        return setmealService.getSetmealById(id);
    }
    @PutMapping("/{id}")
    @ApiOperation("根据id修改套餐")
    public void updateSetmealById(@PathVariable Integer id,@RequestBody CreateSetmealReqDTO createSetmealReqDTO) {
        setmealService.updateSetmealById(id,createSetmealReqDTO);
    }

    @PutMapping("/enable/{id}")
    @ApiOperation("根据id启用套餐")
    public void enableSetmealById(@PathVariable Integer id) {
        setmealService.enableSetmealById(id);
    }

    @PutMapping("/disable/{id}")
    @ApiOperation("根据id禁用套餐")
    public void disableSetmealById(@PathVariable Integer id) {
        setmealService.disableSetmealById(id);
    }
    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除套餐")
    public void deleteSetmealById(@PathVariable Integer id) {
        setmealService.deleteSetmealById(id);
    }
    @GetMapping("/queryCheckCategory/{id}")
    @ApiOperation("根据id查询检查项目录")
    public List<ItemAndGroupResDTO> queryCheckCategory(@PathVariable Integer id) {
        return setmealService.queryCheckCategory(id);
    }

}
